package com.xhui.vimarket.zkplus.zul.attr.mod.impl;t java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.directwebremoting.util.Logger;
import org.zkoss.zk.ui.Component;
import org.zkoss.zul.Button;
import org.zkoss.zul.Column;
import org.zkoss.zul.Columns;
import org.zkoss.zul.Foot;
import org.zkoss.zul.Footer;
import org.zkoss.zul.Grid;
import org.zkoss.zul.Row;
import org.zkoss.zul.Rows;

import com.xhui.crm.common.vo.RetVO;com.xhui.vimarket.zkplusui.vimarket.zkplus.util.com.xhui.vimarket.zkplusrt com.xhui.vimarket.zkpluscom.xhui.vimarket.zkplusxt;
import com.xhui.vimarket.zkplus.zulcom.xhui.vimarket.zkplusxecListener;
import com.xhui.vimcom.xhui.vimarket.zkplusl.attr.bean.AttrInst;
import comcom.xhui.vimarket.zkpluszkplus.zul.attr.bean.AttrTmpl;com.xhui.vimarket.zkplusi.vimarket.zkplus.zul.attr.bean.ValiVo;
com.xhui.vimarket.zkplus.vimarket.zkplus.zul.attr.evt.GridPageBcom.xhui.vimarket.zkplusrt com.xhui.vimarket.zkplus.zul.attr.mod.AttrCompFactory;
import com.xhcom.xhui.vimarket.zkpluslus.zul.attr.util.AttrConstants;

/**
 * @版权：福富软件 版权所有 (c) 2010
 * @文件：com.xhui.vimarket.zkplus.zul.attr.mod.impl.AttrGridComp.java
 * @所含类：
 * @author: wuyx
 * @version: V1.0
 * @see:
 * @创建日期：2010-12-20
 * @功能说明：属性控件接口
 * @修改记录： =============================================================<br>
 *        日期:2010-12-20 创建
 *        =============================================================<br>
 */
public final class AttrGridComp extends AttrBaseComp {
    
    /**
     * 实例.
     */
    private static AttrGridComp inst   = new AttrGridComp();
    
    /**
     * 日志.
     */
    private static Logger       logger = Logger.getLogger(AttrGridComp.class);
    
    /**
     * 构造函数. 
     */
    private AttrGridComp() {
    }
    
    /**
     * 获取实例.
     * 
     * @return AttrBaseComp
     */
    public static AttrGridComp instance() {
        return AttrGridComp.inst;
    }
    
    /**
     * 生成组件.
     * 
     * @param attrExt 组件控件
     * @param attrTmpl 组件模板
     * @param comp 显示容器组件
     */
    @Override
    public void create(final AttrExt attrExt, final AttrTmpl attrTmpl, final Component comp) {
        super.create(attrExt, attrTmpl, comp);
        // sub comp max xy
        final int[] maxxy = AttrBaseComp.getMaxxy(attrExt, attrTmpl);
        if (maxxy[0] < 2) {
            maxxy[0] = 1;
        }
        final int onew = 100 / maxxy[0];
        
        // comp log
        if (AttrGridComp.logger.isDebugEnabled()) {
            attrExt.appendInnerComp("<grid");
            attrExt.appendInnerComp(" width=\"100%\">");
            attrExt.appendInnerCompAttr(AttrBaseComp.COMP_MODE, attrTmpl.getDisplayMode());
            attrExt.appendInnerCompAttr(AttrBaseComp.COMP_ATTRID, "" + attrTmpl.getAttrId());
            attrExt.appendInnerComp("<columns>");
        }
        
        // grid
        final Grid grid = new Grid();
        grid.setWidth("100%");
        grid.setStyle("border:0px;");
        grid.setAttribute(AttrBaseComp.COMP_MODE, attrTmpl.getDisplayMode());
        grid.setAttribute(AttrBaseComp.COMP_ATTRID, attrTmpl.getAttrId());
        // gird.setTitle(attrTmpl.getName());
        // columns && column
        final Columns columns = new Columns();
        
        // add to zul
        grid.setParent(comp);
        columns.setParent(grid);
        for (int i = 0; i < maxxy[0]; i++) {
            final Column column = new Column();
            if (i + 1 < maxxy[0]) { // 前面的列设宽度
                column.setWidth(onew + "%");
            }
            column.setParent(columns);
            // comp log
            if (AttrGridComp.logger.isDebugEnabled()) {
                attrExt.appendInnerComp("<column");
                attrExt.appendInnerComp(" width=\"" + onew + "%\" />");
            }
        }
        // comp log
        if (AttrGridComp.logger.isDebugEnabled()) {
            attrExt.appendInnerComp("</columns>");
            attrExt.appendInnerComp("<rows>");
        }
        
        // rows
        final Rows rows = new Rows();
        // add to zul
        rows.setParent(grid);
        final int sum = attrTmpl.getAttrTmplListCount();
        int line = -1;
        // Row
        Row row = null;
        String spans = null; // 行宽度布局
        int rowSpansNum = -1; // 自动布局情况下，当行数量
        int maxsize = AttrConstants.GRID_MAX_SIZE;
        if (attrTmpl.getPageSize() > 0) { // 是否分页
            maxsize = attrTmpl.getLastIndex() + attrTmpl.getPageSize();
        }
        for (int i = 0; i < sum && i < maxsize; i++) {
            final AttrTmpl subAttrTmpl = attrTmpl.getAttrTmplList(i);
            if ((AttrBaseComp.SORT_BY_XY == attrExt.getAttrAda().getSortType() && line != subAttrTmpl
                .getYAddr())
                || (AttrBaseComp.SORT_BY_ORDER == attrExt.getAttrAda().getSortType() && (rowSpansNum < 0 || rowSpansNum >= attrTmpl
                    .getXAddr()))) { // 新行，根据模式进行计算
                if (row != null && !"".equals(spans)) {
                    row.setSpans(spans);
                }
                // if (line != -1) {
                row = new Row();
                row.setParent(rows);
                spans = "";
                rowSpansNum = 0;
                // comp log
                if (AttrGridComp.logger.isDebugEnabled()) {
                    if (line != -1) {
                        attrExt.appendInnerComp("</row>");
                    }
                    attrExt.appendInnerComp("<row>");
                }
                line = subAttrTmpl.getYAddr();
            }
            spans = spans + ("".equals(spans) ? ""
                : ",") + (subAttrTmpl == null ? "1"
                : subAttrTmpl.getWidth() == 0 ? "1"
                    : subAttrTmpl.getWidth()); // 行格分布拼接
            rowSpansNum += (subAttrTmpl.getWidth() == 0 ? 1
                : subAttrTmpl.getWidth());
            AttrCompFactory.getInst(subAttrTmpl.getDisplayMode()).create(attrExt, subAttrTmpl, row);
            if (i + 1 == sum && row != null && !"".equals(spans)) { // 设置最后一个行格分布
                row.setSpans(spans);
            }
        }
        
        if (maxsize < sum) {
            attrTmpl.setLastIndex(maxsize);
        }
        
        // 生成foot
        if (maxsize < AttrConstants.GRID_MAX_SIZE) {
            Foot foot = new Foot();
            foot.setParent(grid);
            Footer footer = new Footer();
            footer.setSpan(maxxy[0]);
            footer.setParent(foot);
            Button btn = new GridPageButtonExt(attrExt, attrTmpl, comp);
            btn.setLabel("更多");
            btn.setParent(footer);
            btn.setAutodisable("self");
            if (maxsize >= sum) {
                foot.setVisible(false);
            }
        }
        
        if (AttrGridComp.logger.isDebugEnabled()) {
            attrExt.appendInnerComp("</row>");
            attrExt.appendInnerComp("</rows>");
            attrExt.appendInnerComp("</grid>");
        }
        
        if (attrTmpl.isReadOnly()) {
            ZkUiUtil.setDisabled(grid, true);
        }
        if (!attrTmpl.isDisplay()
            || AttrConstants.DISPLAY_STYLE_PANEL_HIDE.equals(attrTmpl.getDisplayStyle())) {
            grid.setVisible(false); // 隐藏
        }
        
        super.afterCreate(attrExt, attrTmpl, comp);
    }
    
    /**
     * 设置值.
     * 
     * @param attrExt 组件控件
     * @param comp 组件
     * @param attrInstList 属性实例
     */
    @Override
    public void setValue(final AttrExt attrExt, final Component comp,
        final List<AttrInst> attrInstList, Map<String, Integer> attrViewMap) {
        super.setValue(attrExt, comp, attrInstList, attrViewMap);
        // 自身不实例化，取下级数据
        // grid // rows
        final Component compRows = AttrGridComp.getRows(comp);
        final List<Component> subRowList = compRows.getChildren();
        final int sum = subRowList == null ? 0
            : subRowList.size();
        AttrGridComp.logger.debug("subRowList size:" + sum);
        for (int i = 0; i < sum; i++) {
            final Component subRow = subRowList.get(i);
            final List<Component> subCompRootBoxList = subRow.getChildren();
            final int jsum = subCompRootBoxList == null ? 0
                : subCompRootBoxList.size();
            for (int j = 0; j < jsum; j++) {
                final Component subCompRootBox = subCompRootBoxList.get(j);
                if (subCompRootBox != null) {
                    AttrCompFactory.getInstByComponent(subCompRootBox).setValue(attrExt,
                        subCompRootBox, attrInstList, attrViewMap);
  com.xhui.vimarket.zkplus
            }
        }
    }
    
    /**com.xhui.vimarket.zkplusritDoc}
     * @see com.xhui.vimarket.zkplus.zul.attr.mod.AttrComp
     * #setRemovedValue(com.xhui.vimarket.zkplus.zul.attr.AttrExt, org.zkoss.zk.ui.Component, java.util.List)
     * @author wuyx
     * 2011-4-8 wuyx
     */
    public void setRemovedValue(final AttrExt attrExt, final Component comp,
        final List<AttrInst> attrInstList) {
        super.setRemovedValue(attrExt, comp, attrInstList);
        // 自身不实例化，取下级数据
        // grid // rows
        final Component compRows = AttrGridComp.getRows(comp);
        final List<Component> subRowList = compRows.getChildren();
        final int sum = subRowList == null ? 0
            : subRowList.size();
        AttrGridComp.logger.debug("subRowList size:" + sum);
        for (int i = 0; i < sum; i++) {
            final Component subRow = subRowList.get(i);
            final List<Component> subCompRootBoxList = subRow.getChildren();
            final int jsum = subCompRootBoxList == null ? 0
                : subCompRootBoxList.size();
            for (int j = 0; j < jsum; j++) {
                final Component subCompRootBox = subCompRootBoxList.get(j);
                if (subCompRootBox != null) {
                    AttrCompFactory.getInstByComponent(subCompRootBox).setRemovedValue(attrExt,
                        subCompRootBox, com.xhui.vimarket.zkplus
                }
            }
        }
  com.xhui.vimarket.zkplus/**
     * {@inheritDoc}
     * @see com.xhui.vimarket.zkplus.zul.attr.mod.AttrComp
     * #setRemovedValue(com.xhui.vimarket.zkplus.zul.attr.AttrExt, org.zkoss.zk.ui.Component, java.util.List)
     * @author wuyx
     * 2011-4-8 wuyx
     */
    public void setDiasbledValue(final AttrExt attrExt, final Component comp,
        final List<AttrInst> attrInstList) {
        super.setRemovedValue(attrExt, comp, attrInstList);
        // 自身不实例化，取下级数据
        // grid // rows
        final Component compRows = AttrGridComp.getRows(comp);
        final List<Component> subRowList = compRows.getChildren();
        final int sum = subRowList == null ? 0
            : subRowList.size();
        AttrGridComp.logger.debug("subRowList size:" + sum);
        for (int i = 0; i < sum; i++) {
            final Component subRow = subRowList.get(i);
            final List<Component> subCompRootBoxList = subRow.getChildren();
            final int jsum = subCompRootBoxList == null ? 0
                : subCompRootBoxList.size();
            for (int j = 0; j < jsum; j++) {
                final Component subCompRootBox = subCompRootBoxList.get(j);
                if (subCompRootBox != null) {
                    AttrCompFactory.getInstByComponent(subCompRootBox).setDisabledValue(attrExt,
                        subCompRootBox, attrInstList);
                }
            }
        }
    }
    
    /**
     * 获取值.
     * 
     * @param attrExt 组件控件
     * @param comp 组件
     * @return ArrayList<AttrInst>
     */
    @Override
    public ArrayList<AttrInst> getValue(final AttrExt attrExt, final Component comp) {
        super.getValue(attrExt, comp);
        final ArrayList<AttrInst> retList = new ArrayList<AttrInst>();
        // 自身不实例化，取下级数据
        // grid // rows
        final Component compRows = AttrGridComp.getRows(comp);
        final List<Component> subRowList = compRows.getChildren();
        final int sum = subRowList == null ? 0
            : subRowList.size();
        AttrGridComp.logger.debug("subRowList size:" + sum);
        for (int i = 0; i < sum; i++) {
            final Component subRow = subRowList.get(i);
            final List<Component> subCompRootBoxList = subRow.getChildren();
            final int jsum = subCompRootBoxList == null ? 0
                : subCompRootBoxList.size();
            for (int j = 0; j < jsum; j++) {
                final Component subCompRootBox = subCompRootBoxList.get(j);
                if (subCompRootBox != null) {
                    final ArrayList<AttrInst> subRetList = AttrCompFactory.getInstByComponent(
                        subCompRootBox).getValue(attrExt, subCompRootBox);
                    if (subRetList != null) {
                        retList.addAll(subRetList);
          com.xhui.vimarket.zkplus              }
            }
        }
  com.xhui.vimarket.zkplustList;
    }

    /**
     * {@inheritDoc}
     * @see com.xhui.vimarket.zkplus.zul.attr.mod.impl.AttrBaseComp#signRuleHint(com.xhui.vimarket.zkplus.zul.attr.AttrExt, org.zkoss.zk.ui.Component)
     * @author wuyx
     * 2012-2-16 wuyx
     */
    @Override
    public ArrayList<ValiVo> signRuleHint(AttrExt attrExt, Component comp) {
        return null;
    }
    
    /**
     * 获取值.
     * 
     * @param attrExt 组件控件
     * @param comp 组件
     * @return ArrayList<AttrInst>
     */
    @Override
    public ArrayList<AttrInst> getNullValue(final AttrExt attrExt, final Component comp) {
        super.getValue(attrExt, comp);
        final ArrayList<AttrInst> retList = new ArrayList<AttrInst>();
        // 自身不实例化，取下级数据
        // grid // rows
        final Component compRows = AttrGridComp.getRows(comp);
        final List<Component> subRowList = compRows.getChildren();
        final int sum = subRowList == null ? 0
            : subRowList.size();
        AttrGridComp.logger.debug("subRowList size:" + sum);
        for (int i = 0; i < sum; i++) {
            final Component subRow = subRowList.get(i);
            final List<Component> subCompRootBoxList = subRow.getChildren();
            final int jsum = subCompRootBoxList == null ? 0
                : subCompRootBoxList.size();
            for (int j = 0; j < jsum; j++) {
                final Component subCompRootBox = subCompRootBoxList.get(j);
                if (subCompRootBox != null) {
                    final ArrayList<AttrInst> subRetList = AttrCompFactory.getInstByComponent(
                        subCompRootBox).getNullValue(attrExt, subCompRootBox);
                    if (subRetList != null) {
                        retList.addAll(subRetList);
                    }
                }
            }
        }
        return retList;
    }
    
    /**
     * 取空值属性实例.
     * 
     * @param attrExt 组件控件
     * @param attrTmpl 模板
     * @return ArrayList<AttrInst>
     */
    @Override
    public ArrayList<AttrInst> getNullValue(final AttrExt attrExt, final AttrTmpl attrTmpl) {
        super.getNullValue(attrExt, attrTmpl);
        final ArrayList<AttrInst> retList = new ArrayList<AttrInst>();
        for (final AttrTmpl subAttrTmpl : attrTmpl.getAttrTmplList()) {
            final ArrayList<AttrInst> subRetList = AttrCompFactory.getInst(
                subAttrTmpl.getDisplayMode()).getNullValue(attrExt, subAttrTmpl);
            if (subRetList != null) {
                retList.addAll(subRetList);
            }
        }
        return retList;
    }
    
    /**
     * 清空值.
     * 
     * @param attrExt 组件控件
     * @param comp 组件
     */
    @Override
    public void clean(final AttrExt attrExt, final Component comp) {
        // 自身不实例化，取下级数据
        // grid // rows
        final Component compRows = AttrGridComp.getRows(comp);
        final List<Component> subRowList = compRows.getChildren();
        final int sum = subRowList == null ? 0
            : subRowList.size();
        AttrGridComp.logger.debug("subRowList size:" + sum);
        for (int i = 0; i < sum; i++) {
            final Component subRow = subRowList.get(i);
            final List<Component> subCompRootBoxList = subRow.getChildren();
            final int jsum = subCompRootBoxList == null ? 0
                : subCompRootBoxList.size();
            for (int j = 0; j < jsum; j++) {
                final Component subCompRootBox = subCompRootBoxList.get(j);
                if (subCompRootBox != null) {
                    AttrCompFactory.getInstByComponent(subCompRootBox).clean(attrExt,
                        subCompRootBox);
                }
            }
        }
    }
    
    /**
     * 设置为不允许修改.
     * 
     * @param attrExt 组件控件
     * @param comp 组件
     * @param tflag 设置值，true/false
     */
    @Override
    public void setDisabled(AttrExt attrExt, Component comp, boolean tflag) {
        super.setDisabled(attrExt, comp, tflag);
        // 自身不实例化，取下级数据
        // grid // rows
        final Component compRows = AttrGridComp.getRows(comp);
        final List<Component> subRowList = compRows.getChildren();
        final int sum = subRowList == null ? 0
            : subRowList.size();
        AttrGridComp.logger.debug("subRowList size:" + sum);
        for (int i = 0; i < sum; i++) {
            final Component subRow = subRowList.get(i);
            final List<Component> subCompRootBoxList = subRow.getChildren();
            final int jsum = subCompRootBoxList == null ? 0
                : subCompRootBoxList.size();
            for (int j = 0; j < jsum; j++) {
                final Component subCompRootBox = subCompRootBoxList.get(j);
                if (subCompRootBox != null) {
                    AttrCompFactory.getInstByComponent(subCompRootBox).setDisabled(attrExtcom.xhui.vimarket.zkplus            subCompRootBox, tflag);
com.xhui.vimarket.zkplus }
            }
        }
    }
    
    /**
     * {@inheritDoc}
     * @see com.xhui.vimarket.zkplus.zul.attr.mod.AttrComp#
     * exec(com.xhui.vimarket.zkplus.zul.attr.ada.AttrExecListener)
     * @author wuyx
     * 2011-3-16 wuyx
     */
    @SuppressWarnings("unchecked")
    @Override
    public void exec(final AttrExt attrExt, final Component comp, AttrExecListener attrExecListener) {
        super.exec(attrExt, comp, attrExecListener);
        if (attrExecListener == null) {
            return;
        }
        // 自身不实例化，取下级数据
        // grid // rows
        final Component compRows = AttrGridComp.getRows(comp);
        final List<Component> subRowList = compRows.getChildren();
        final int sum = subRowList == null ? 0
            : subRowList.size();
        AttrGridComp.logger.debug("subRowList size:" + sum);
        for (int i = 0; i < sum; i++) {
            final Component subRow = subRowList.get(i);
            final List<Component> subCompRootBoxList = subRow.getChildren();
            final int jsum = subCompRootBoxList == null ? 0
                : subCompRootBoxList.size();
            for (int j = 0; j < jsum; j++) {
                final Component subCompRootBox = subCompRootBoxList.get(j);
                if (subCompRootBox != null) {
                    // 下级
                    AttrCompFactory.getInstByComponent(subCompRootBox).exec(attrExt,
                        subCompRootBox, attrExecListener);
                    // 自身
  com.xhui.vimarket.zkplus   attrExecListener.onEvent(subCompRootBox, attrExcom.xhui.vimarket.zkplus      }
            }
        }
    }
    
    /**
     * {@inheritDoc}
     * @see com.xhui.vimarket.zkplus.zul.attr.mod.impl.AttrBaseComp
     * #validate(com.xhui.vimarket.zkplus.zul.attr.AttrExt, org.zkoss.zk.ui.Component)
     * @author wuyx
     * 2011-3-22 wuyx
     */
    @Override
    public List<RetVO> validate(AttrExt attrExt, Component comp) {
        final ArrayList<RetVO> retList = new ArrayList<RetVO>();
        // 自身不实例化，取下级数据
        // grid // rows
        final Component compRows = AttrGridComp.getRows(comp);
        final List<Component> subRowList = compRows.getChildren();
        final int sum = subRowList == null ? 0
            : subRowList.size();
        AttrGridComp.logger.debug("subRowList size:" + sum);
        for (int i = 0; i < sum; i++) {
            final Component subRow = subRowList.get(i);
            final List<Component> subCompRootBoxList = subRow.getChildren();
            final int jsum = subCompRootBoxList == null ? 0
                : subCompRootBoxList.size();
            for (int j = 0; j < jsum; j++) {
                final Component subCompRootBox = subCompRootBoxList.get(j);
                if (subCompRootBox != null) {
                    final List<RetVO> subRetList = AttrCompFactory.getInstByComponent(
                        subCompRootBox).validate(attrExt, subCompRootBox);
                    if (subRetList != null) {
             com.xhui.vimarket.zkplusist.addAll(subRetList);
                    }
           com.xhui.vimarket.zkplus     }
        }
        return retList;
    }
    
    /**
     * {@inheritDoc}
     * @see com.xhui.vimarket.zkplus.zul.attr.mod.impl.AttrBaseComp
     * #refreshButtonText(com.xhui.vimarket.zkplus.zul.attr.AttrExt, org.zkoss.zk.ui.Component)
     * @author wuyx
     * 2011-3-24 wuyx
     */
    @Override
    public void refreshButtonText(AttrExt attrExt, Component comp, final List<AttrInst> attrInstList) {
        final ArrayList<RetVO> retList = new ArrayList<RetVO>();
        // 自身不实例化，取下级数据
        // grid // rows
        final Component compRows = AttrGridComp.getRows(comp);
        final List<Component> subRowList = compRows.getChildren();
        final int sum = subRowList == null ? 0
            : subRowList.size();
        AttrGridComp.logger.debug("subRowList size:" + sum);
        for (int i = 0; i < sum; i++) {
            final Component subRow = subRowList.get(i);
            final List<Component> subCompRootBoxList = subRow.getChildren();
            final int jsum = subCompRootBoxList == null ? 0
                : subCompRootBoxList.size();
            for (int j = 0; j < jsum; j++) {
                final Component subCompRootBox = subCompRootBoxList.get(j);
                if (subCompRootBox != null) {
                    AttrCompFactory.getInstByComponent(subCompRootBox).refreshButtonText(attrExt,
                        subCompRootBox, attrInstList);
                }
            }
        }
    }
    
    /**
     * .
     * 
     * @param comp Component
     * @return Rows
     * @author wuyx
     * 2011-5-9 wuyx 
     */
    public static Rows getRows(final Component comp) {
        return (Rows) comp.getcom.xhui.vimarket.zkplustNextSibling();
    }
    
    /**
     * 设置信息是否可见.
     * 
     * @param comp 组件
     * @param attrViewMap 信息是否可见映照
     */
    @Override
    /**
     * {@inheritDoc}
     * @see com.xhui.vimarket.zkplus.zul.attr.mod.AttrComp
     * #setAttrView(org.zkoss.zk.ui.Component, Map<String, Integer>)
     * @author chenmh
     * 2011-6-16 chenmh
     */
    public void setAttrView(final Component comp, Map<String, Integer> attrViewMap) {
        super.setAttrView(comp, attrViewMap);
        // 自身不实例化，取下级数据
        // grid // rows
        final Component compRows = AttrGridComp.getRows(comp);
        final List<Component> subRowList = compRows.getChildren();
        final int sum = subRowList == null ? 0
            : subRowList.size();
        AttrGridComp.logger.debug("subRowList size:" + sum);
        for (int i = 0; i < sum; i++) {
            final Component subRow = subRowList.get(i);
            final List<Component> subCompRootBoxList = subRow.getChildren();
            final int jsum = subCompRootBoxList == null ? 0
                : subCompRootBoxList.size();
            for (int j = 0; j < jsum; j++) {
                final Component subCompRootBox = subCompRootBoxList.get(j);
                if (subCompRootBox != null) {
                    AttrCompFactory.getInstByComponent(subCompRootBox).setAttrView(comp,
                        attrViewMap);
    com.xhui.vimarket.zkplus            }
        }
    }
    
    /**
     * 设置信息是否可见.
     * 
     * @param comp 组件
     * @param attrViewMap 信息是否可见映照
     */
    @Override
    /**
     * {@inheritDoc}
     * @see com.xhui.vimarket.zkplus.zul.attr.mod.AttrComp
     * #setAttrView(org.zkoss.zk.ui.Component, Map<String, Integer>)
     * @author chenmh
     * 2011-6-16 chenmh
     */
    public void setAttrConstrain(final Component comp, Map<Object, String> attrConstrainMap) {
        super.setAttrConstrain(comp, attrConstrainMap);
        // 自身不隐藏，取下级数据
        // grid // rows
        final Component compRows = AttrGridComp.getRows(comp);
        if (compRows != null) {
            final List<Component> subRowList = compRows.getChildren();
            final int sum = subRowList == null ? 0
                : subRowList.size();
            AttrGridComp.logger.debug("subRowList size:" + sum);
            for (int i = 0; i < sum; i++) {
                final Component subRow = subRowList.get(i);
                final List<Component> subCompRootBoxList = subRow.getChildren();
                final int jsum = subCompRootBoxList == null ? 0
                    : subCompRootBoxList.size();
                for (int j = 0; j < jsum; j++) {
                    final Component subCompRootBox = subCompRootBoxList.get(j);
                    if (subCompRootBox != null) {
                        AttrCompFactory.getInstByComponent(subCompRootBox).setAttrConstrain(
                            subCompRootBox, attrConstrainMap);
                        System.out.println(AttrCompFactory.getInstByComponent(subCompRootBox)
                            .getClass().getName());
                    }
                }
            }
        }
    }
    
}
